const mysql = require('mysql2');
const dbConfig = require('../config/db');

const pool = mysql.createPool(dbConfig)

const poolPromise = pool.promise();

const queryData = async (sql) => {
    const res = await poolPromise.execute(sql);
    console.log('打印***res', res[0])
    return res[0]
}

const insertData = async (sql) => {
    const res = await poolPromise.execute(sql);
    console.log('打印***res[0]', res[0])
    // fieldCount: 0,affectedRows: 1,insertId: 21,info: '',serverStatus: 2,warningStatus: 0
    return res[0]
}



// let sql = `select * from test_user`
// sql = `delete from test_user where id = 11`
// sql = `insert into test_user (name,age) values ("${name}", 18)`
// sql = `update test_user set name=1,age=12 where id=12`

// insertData(sql)



module.exports = poolPromise
